﻿<Page
    x:Class="TestingApp.Pages.Admin.AdminPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:local="clr-namespace:TestingApp.Pages.Admin"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    Title="AdminPage"
    d:DesignHeight="450"
    d:DesignWidth="800"
    DataContext="{Binding Source={StaticResource VmLocator}, Path=AdminPageViewMode}"
    mc:Ignorable="d">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <UniformGrid Columns="4">
            <Button
                Margin="5"
                Command="{Binding AddTest}"
                Content="Добавить КР" />
        </UniformGrid>

        <Grid Grid.Row="1">
            <ItemsControl ItemsSource="{Binding Tests}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border
                            Margin="5"
                            Padding="5"
                            BorderBrush="Black"
                            BorderThickness="1"
                            CornerRadius="5">
                            <Border.InputBindings>
                                <MouseBinding Command="{Binding RelativeSource={RelativeSource AncestorType=Page}, Path=DataContext.OpenTest}" 
                                              Gesture="LeftClick" />
                            </Border.InputBindings>
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="1*" />
                                    <ColumnDefinition Width="1*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <TextBlock
                                    Margin="5"
                                    VerticalAlignment="Center"
                                    Text="{Binding Title}" />
                                <TextBlock
                                    Grid.Column="1"
                                    Margin="5"
                                    VerticalAlignment="Center"
                                    Text="{Binding QuestionCount, StringFormat='Кол-во вопросов: {0}'}"
                                    TextAlignment="Right" />
                                <Button
                                    Grid.Column="2"
                                    Margin="25,5"
                                    Padding="5"
                                    Command="{Binding RelativeSource={RelativeSource AncestorType=Page}, 
                                    Path=DataContext.RemoveTest}"
                                    CommandParameter="{Binding}"
                                    Content="Удалить" />
                            </Grid>
                        </Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </Grid>
    </Grid>
</Page>